package lt.laimis.shop.web.action.product;

import lt.laimis.shop.web.action.node.NodeAcionBean;
import lt.laimis.shop.service.product.Product;
import lt.laimis.shop.service.product.ProductService;

import java.util.List;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.UrlBinding;

/**
 * Created by IntelliJ IDEA.
 * User: laimis
 * Date: Jul 18, 2008
 * Time: 4:32:22 PM
 * To change this template use File | Settings | File Templates.
 */

@UrlBinding("/product/list.do")
public class ListActionBean extends NodeAcionBean {
    private List<Product> productList;

    public List<Product> getProductList() {
        if (productList == null && productService != null) {
            this.productList = productService.getProductByParentId("");
        }
        return productList;
    }

    public void setProductList(List<Product> productList) {
        this.productList = productList;
    }

    @DefaultHandler
    public Resolution addition() {
        if(getCurrentNode() != null && productService != null){
             this.productList = productService.getProductByParentId(getCurrentNode());
        }
        return new ForwardResolution("/product/list.jsp");
    }

}
